<?= \common\widgets\Asset::widget(['type'=>['viewer']])?>
<div class="col-sm-12 search-collapse">
    <form id="role-form">
        <div class="select-list">
            <ul>
                <li class="select-time">
                    <label>注册时间： </label>
                    <?= \common\widgets\FormInput::widget(['name'=>'input','extend'=>['name'=>'between[create_time][start]','id'=>'startTime','place'=>'开始时间']])?>
                    <span>-</span>
                    <?= \common\widgets\FormInput::widget(['name'=>'input','extend'=>['name'=>'between[create_time][end]','id'=>'endTime','place'=>'结束时间']])?>
                </li>
                <li><?= \common\widgets\FormInput::widget(['name'=>'input|ID','extend'=>['name'=>'where[id]']])?></li>
                <li>
                    <?= $this->render('/iframe',['name'=>'searchbtn|搜索'])?>
                    <?= $this->render('/iframe',['name'=>'resetbtn|重置'])?>
                </li>
            </ul>
        </div>
    </form>
</div>
<div class="col-sm-12 select-table table-striped">
    <table id="bootstrap-table"></table>
</div>

<?php $this->beginBlock('script'); ?>
<script>
    $(function () {
        var options = {
            modalName: "用户",
            sortName:'create_time',
            sortOrder: "desc",
            detailUrl: decodeURIComponent("<?=\yii\helpers\Url::toRoute(['detail','id'=>'{id}'])?>"),
            columns: [
                {field: 'id', title: 'ID'},
                {
                    title: '会员信息',
                    field: 'nickname',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var html = `<img id="img_${row.id}" src="${row.avatar}" style="width: 80px">`;
                        return html+`<p>${value}</p>`;
                    }
                },
                {field: 'second_title', title: '推荐人'},
                {field: 'create_time', title: '注册时间'},
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return '<?=$this->render("/iframe",["name"=>"formopbtn","extend"=>["type"=>["detail"],"rowId"=>"row.id"]])?>';
                    }
                }
            ],
            onPostBody:function (data) {
                for (let i = 0; i < data.length; i++) {
                    new Viewer(document.getElementById('img_'+data[i].id),{navbar:false,title:false});
                }
            }
        };
        $.table.init(options);
    });
</script>
<?php $this->endBlock(); ?>

